package com.bianmaba.samples.webflux.router;

import com.bianmaba.samples.webflux.handler.UserHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.web.reactive.function.server.RequestPredicates;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.RouterFunctions;
import org.springframework.web.reactive.function.server.ServerResponse;

/**
 * @program: samples
 * @description:
 * @author: Chenjiabin
 * @create: 2019/8/7 10:25
 **/
@Configuration
public class UserRouter {
    @Bean
    public RouterFunction<ServerResponse> helloXttblog(UserHandler handler) {
        return RouterFunctions.route(RequestPredicates.GET("/get")
                        .and(RequestPredicates.accept(MediaType.TEXT_PLAIN)),
                handler::get);
    }
}
